import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

public class Read {
    public static void main(String arge[]) {

        long lasting = System.currentTimeMillis();

        try {
            File f = new File("D:\\GitHOME\\information\\text.xml");
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document doc = builder.parse(f);
            NodeList nl = doc.getElementsByTagName("spot");
            for (int i = 0; i < nl.getLength(); i++) {
                System.out.print("景点名称:"+ doc.getElementsByTagName("name").item(i).getFirstChild().getNodeValue());
                System.out.println("景点编号:"+ doc.getElementsByTagName("id").item(i).getFirstChild().getNodeValue());
                System.out.println("景点介绍:"+ doc.getElementsByTagName("intro").item(i).getFirstChild().getNodeValue());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
